<?php

class AdminModule extends CWebModule {

    //declare variables
    private $_assetsUrl;
    public $moduleLabel = '';

    public function init() {
        // this method is called when the module is being created
        // you may place code here to customize the module or the application
        // import the module-level models and components
        $this->setImport(array(
            'admin.models.*',
            'admin.components.*',
        ));

        Yii::app()->name = 'Open Admin';
        Yii::app()->language = 'en';
//        Yii::app()->timeZone='Asia/Saigon';

        $this->defaultController = 'main';
        $this->moduleLabel = Yii::app()->name;

        $adminSession = new AdminSession();
        $adminSession->setSessionName(Yii::app()->params['area']['admincp'] . '_SESSION');

        Yii::app()->setComponent('session', $adminSession);
        Yii::app()->setComponent('admin', new WebAdmin());
        Yii::app()->admin->setReturnUrl(Yii::app()->createAbsoluteUrl('admin/main/index'));
        Yii::app()->getErrorHandler()->errorAction = 'admin/main/error';
    }

    public function beforeControllerAction($controller, $action) {
        if (parent::beforeControllerAction($controller, $action)) {
            // this method is called before any module controller action is performed
            // you may place customized code here
            return true;
        }
        else
            return false;
    }

    public function getAssetsUrl() {
        $this->_assetsUrl=  'http://thanglongco.vn'.'/'.'themes'.'/'.'admin'.'/'.'assets';
        return $this->_assetsUrl;
    }

}
